tools/libxl: Fix legacy migration following COLO backchannel breakage
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 14 Apr 2016 19:54:15 +0000 (20:54 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 15 Apr 2016 11:01:15 +0000 (12:01 +0100)
commitde28b189bd329dd20a245a318be8feea2c4cc60a
treef8009f39228959cb7193997754a2101db274c318
parent247d38c870192c39442363ea633aa470e93fc186
tools/libxl: Fix legacy migration following COLO backchannel breakage

c/s f5d947bf1b "tools/libxl: add back channel support to read stream"
made a bogus adjustment to libxl__stream_read_start(), including
removing the comment hinting at what was going on, which breaks
conversion of a legacy migration stream.

Symptoms look like:

  root@anonymi:~ # xl migrate domU host
  migration target: Ready to receive domain.
  Saving to migration stream new xl format (info 0x1/0x0/2677)
  xc: error: error polling suspend notification channel: -1: Internal error
  Loading new save file <incoming migration stream> (new xl fmt info 0x1/0x0/2677)
   Savefile contains xl domain config in JSON format
  Parsing config from <saved>
  libxl: error: libxl_stream_read.c:327:stream_header_done: Invalid ident: expected 0x4c6962786c466d74, got 0x01f00f0000000000
  libxl: error: libxl_utils.c:430:libxl_read_exactly: file/stream truncated reading ipc msg header from domain 1 save/restore helper stdout pipe

The adjustment is not required for backchannel support (as there is no
interaction between back channels and legacy conversion), and caused
stream->fd to be latched in the datacopier before legacy conversion
substitutes it for the fd which is the output of the conversion script.

This causes libxl to consume data from the legacy stream rather than the
v2 stream, and for the conversion script to encounter an error as the
legacy stream appears to skip ahead.

Undo the adjustments to libxl__stream_read_start(), and introduce a
better description of what is going on.  Introduce some extra assertions
to try and catch similar breakage in the future.

Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wen Congyang <wency@cn.fujitsu.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Olaf Hering <olaf@aepfle.de>
tools/libxl/libxl_stream_read.c